STEP 6: Now let's change the image to match our random number!

Using the Change Image tool allows us to match the dice image to the random number each time the loop runs!

  • In GRAPHICS, click on . Drag out Change Image and drop it indented INSIDE your loop.
  • Change the image label in the .load_image() command from "person1" to "dice" + str(outcome)

Remember, str() casts the value of outcome to a string, so it can be combined with the string "dice".

To navigate the page using the TAB key, first press ESC to exit the code editor.

# THIS ACTIVITY IS IN PREVIEW ONLY MODE
  • Run Code
  • Submit Work
  • Next Activity
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)